package com.wise.service.cms.content.article;

import com.wise.entities.content.Article;
import com.wise.framework.daomodel.DaoOne4Update;
import com.wise.framework.daomodel.DaoRemove;
import com.wise.summer.v1.cms.content.article.DeleteArticleById;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

import static com.wise.framework.validation.Precondition.checkNotNull;
import static com.wise.model.content.ContentErrMsgs.Err_001600250006;
import static com.wise.model.content.ContentErrMsgs.Err_001600250007;

@Service
@SummerService
public class DeleteArticleService implements SummerServiceBean<DeleteArticleById> {
    @Override
    public void sum(DeleteArticleById model) {
        checkNotNull(model.getId(),this.getClass(),Err_001600250006);
        Article article = DaoOne4Update.s(Article.class,model.getId(),Err_001600250007);

        DaoRemove.s(article);
        model.setSummerResult(true);
    }
}
